--- Example code for 'https://github.com/Frege/frege/issues/47 Issue 47'
module tests.comp.Issue47 where

-- import Prelude.Floating

-- originally, the forall type didn't propagate to the top.
-- This should be fixed by now.
with (f::forall u.[u]->[u]) xs ys = (f xs, f ys)

-- the following must not compile, and give message:
--             type `Integer` is not as polymorphic as suggested 
--             in the annotation where just `u` is announced.
-- wrong1 = with (map (1n+)) ['2', '3'] [true, false]

-- should also work for inner functions
outer xs = with reverse [false, true]
    where
        -- this is a case where we can't give a type annotation
        -- because the type of xs cannot be expressed.
        -- with :: (forall u.[u] -> [u]) -> [Bool] -> ([a], [Bool])
        with (f :: forall u.[u] -> [u]) ys = (f xs, f ys)

--  The following is not allowed anymore:
-- worksnot f xs ys = case f of { (g::forall b.[b]->[b]) -> (g xs, g ys) }

--  This used to compile and give a type error at runtime. No more!
-- typefailure = worksnot (map Double.sqrt) [true, false] ['a', 'b']

main = println $ outer ["Ja", "Ok"]